// const request = require('request');
// const moment = require('moment');
// const partner_code = 'EWEC';
// const credential_code = 'vG9kuvOV6Spn8urbhUCSG8HWY6fMot6x';
// const nonce_str = 'q1231231221asdasd';
// const crypto = require('crypto');
//
// function generate_sign() {
//   var time_stamp = moment().format('x');
//   console.log(time_stamp);
//   var validation_str = partner_code+'&'+time_stamp+'&'+nonce_str+'&'+credential_code;
//   console.log(validation_str);
//   var cipher = crypto.createHash('sha256');
//   cipher.update(validation_str);
//   var sign = cipher.digest('hex').toLowerCase();
//   console.log('generate sign:',sign);
//   return sign;
// }
//
// generate_sign();

var pay = require('./RoyalPay');
var api = require('./MainApi');
var wms = require('./WmsApi');
var wechat = require('./wechat');
var co = require('co');
var token = require('./token');
var request = require('request');
var moment = require('moment');
var fs = require('fs');
var now = moment(1510671221343).format('YYYY年MM月DD日HH时MM分');

console.log(now);
var body = {
  source: 'wechat',
  source_id: 'sdsdsdsdsdsdsd',
  name: 'steftest',
  tel: '12312312321312',
  addr: '',
  id_no: '',
  remark: 'test'
};

var json = {
  name: 'trump',
  tel: '',
  addr: 'white house washington',
  id_no: '',
  remark: '',
}
var customer_id = '1b7fe69ee1344f59a17c10cb1ea431de';
var contact_id = '5cd55371c04940d9bee1bf290ae67a67';
//
// wms.getBoxNo('dc04cf2746a24de0bfa63f127a87a7a3', function (call) {
//   console.log(JSON.parse(call));
// })
// request(' https://qyapi.weixin.qq.com/cgi-bin/media/get?access_token=OkvzrbNZkIdfjSRlLuT7sBWQ827W1UdS7Cbr25zaQlDWMzSDYVdMC8UxXj09I_i_sjqA8pmvZoGeeIwWDuotyEioQBBTvPajRtOi6NXXSuAClf7IPh4wIP9akv6bOc9m0oFEyUBwFB9xx6wSy745mA8SjgcTFGRMpi9gR494huudjp7_GqJF4Nh-t6YXsX4mdySq5Fvdk2CR9sRJT5rHfg&media_id=1b6C6LICWuuBx0oa0ZcorZiY6fRpgq8um4wbrBX0khI0hxURlJKP_774lOHnWXO42').pipe(fs.createWriteStream('../../assets/uhb.jpg', {mode: 0o777}).on('finish', function () {
//   fs.chmodSync('../../assets/uhb.jpg', '777');
// }));

// request('https://item.tuhu.cn/Tires/1/au1-f0-b111.html', function (err, resp, body) {
//   console.log(body);
// })
// wms.get_customers_async().then(function (record) {
//   console.log(record);
// })
// api.get_product_by_sn_async('9421902960031').then(function (record) {
//   console.log(record);
// })
// wms.create_customer_contact(customer_id, json, function (call) {
//   console.log(call);
// })
// wms.get_customer_by_id(customer_id, function (call) {
//   console.log(call);
// })
// wms.get_customers(function (call) {
//   console.log(typeof(call));
// });
//
// wms.get_customer_by_openid('adsd', function (call) {
//   console.log(call);
// })
// wms.get_customers(function (call) {
//   console.log(call);
// })
// wms.get_customer_by_id('591ea5ca6de44375af5a2aeaca29a86c', function (call) {
//   console.log(call);
// });
//
// wms.get_customer_contacts('591ea5ca6de44375af5a2aeaca29a86c', function (call) {
//   console.log(call);
// })
wms.get_customer_orders_by_customer_id('012dfd1efbd442a3801be869e8eae0db', 'all', function (call) {
  console.log(call);
})
// //
// wms.get_order_payment('ecb25bbde610432795aedea077506dfa', function (call) {
//   console.log(JSON.parse(call));
// })
// wms.get_order_specs('ecb25bbde610432795aedea077506dfa', function (call) {
//   console.log(JSON.parse(call));
// })
// wms.getOrderDetail('ecb25bbde610432795aedea077506dfa', function (call) {
//   console.log(call);
// })
// pay.create_jsapi_order('201723', 'some pugs', 10, 'CNY', 'ADMIN123', function (call) {
//   console.log(call);
// });

// pay.get_current_ex(function (call) {
//   console.log(call);
//   console.log(typeof(call));
//   var rate = Number(JSON.parse(call).rate).toFixed(2);
//   console.log('rate:',rate);
// })

// api.getProductBySn('708177108108', function (call) {
//   console.log(call);
//   console.log(typeof(call));
// })

// api.getCombos(function (call) {
//   console.log(JSON.parse(call));
// })
// var order_id = '682ea15140274fe18aa4bebb5ef0dd50';
// var remark = ['http://auewe.oss-ap-southeast-2.aliyuncs.com/products/9421902960031_main.jpg'];
// wms.upload_payment_info(order_id, remark, function (call) {
//   console.log(call);
// })
// co(function *() {
//   var token = yield *wechat.getAccessTokenSync();
//   console.log(typeof(token.body));
//
// })

